// pages/menu/advertise/ad-detail/ad-detail.js
var app = getApp()
var verify = require('../../../../utils/verify-token.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var advertisingStrategyProperty = options.advertisingStrategyProperty
    var advertisingTempName = options.advertisingTempName
    var strategyName = options.strategyName
    var productType = options.productType
    var productModel = options.productModel
    var remark = options.remark
    var indenfier = options.indenfier

    var advertise = JSON.parse(advertisingStrategyProperty);
    var format = "";
    var i = 0;
    var j = 0;
    for(i = 0;i<advertise.length;i++){
      if (advertise[i].fileFormat.length>1){
        for (j = 0; j < advertise[i].fileFormat.length; j++) {
          format += advertise[i].fileFormat[j]
        }
        advertise[i].fileFormat = [format]
      }
    }
        console.log(advertise);
    this.setData({
      sh: app.globalData.screenHeight,
      sw: app.globalData.screenWidth,
      indenfier: indenfier,
      strategyName: strategyName,
      advertisingTempName: advertisingTempName,
      productModel: productModel,
      remark: remark,
      productType: productType,
      advertise: advertise
    })
  },

  getAdDetail(){
    var token = app.globalData.token
    var baseUrl = app.globalData.baseUrl
    var that = this

    wx.request({
      url: baseUrl + 'advertising/checkAdvertisingTemp?id=' + id,
      header: {
        'AUTHORIZATION': token
      },
      success: function (res) {
        if (res.data.code == 60006) {
          verify.clearAll()
        } else if (res.data.code == 200) {
          console.log(res)
          
        } else {
          wx.showModal({
            title: '操作失败',
            content: res.data.message,
          })
        }
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    // this.getAdDetail();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})